Binary images can be displayed inside a grid by adding a BinaryImage control to a template field in the GridView control. This topic shows how to integrate BinaryImage control into GridView control to display images stored as binary images, in data binding scenarios. The ImageData property is used to add the image from the database to the BinaryImage control.
Complete the following steps:
Replace the <cc1:C1BoundField DataField="Picture" HeaderText="Picture" SortExpression="Picture">
tags, within the
</cc1:C1BoundField><Columns></Columns>
tags with the following <cc1:C1TemplateField>
markup:
<cc1:C1TemplateField HeaderText="Picture">
<ItemTemplate>
<cc1:C1BinaryImage ID="C1BinaryImage1" runat="server" ImageData='<%# Eval("Picture") %>' />
</ItemTemplate>
</cc1:C1TemplateField>
Following is the final markup for <cc1:C1GridView>
:
<cc1:C1GridView ID="C1GridView1" runat="server" AutogenerateColumns="False" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1">
<Columns>
<cc1:C1BoundField DataField="CategoryID" HeaderText="CategoryID" ReadOnly="True" SortExpression="CategoryID">
</cc1:C1BoundField>
<cc1:C1BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName">
</cc1:C1BoundField>
<cc1:C1BoundField DataField="Description" HeaderText="Description" SortExpression="Description">
</cc1:C1BoundField>
<cc1:C1TemplateField HeaderText="Picture">
<ItemTemplate>
<cc1:C1BinaryImage ID="C1BinaryImage1" runat="server" ImageData='<%# Eval("Picture") %>' />
</ItemTemplate>
</cc1:C1TemplateField>
</Columns>
</cc1:C1GridView>
The images are displayed with the BinaryImage control integrated into the C1GridView control, as shown in the image below: